package com.fiume.travel.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * <p>
 * Description: spring-mvc的配置类
 * </p>
 *
 * @author fiume
 * @version v1.0.0
 * @create 2021-02-12 23:01
 * @see com.fiume.travel.config
 */
@Configuration
public class SpringMvcConfig extends WebMvcConfigurationSupport {
    @Bean
    public CommonsMultipartResolver multipartResolver(){
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        //默认编码格式
        multipartResolver.setDefaultEncoding("UTF-8");
        //单个请求的最大上传大小(约为13MB)
        multipartResolver.setMaxUploadSize(104857600);
        //文件大小小于此值的文件将存储在内存中，否则将直接存储在磁盘中。(4KB)
        multipartResolver.setMaxInMemorySize(4096);

        return multipartResolver;
    }
}
